package pseudoAssemblerCompiler.twopassassembler.model.referencetable;

import pseudoAssemblerCompiler.twopassassembler.model.assemblerAlgorithms.IViewModel;
import pseudoAssemblerCompiler.twopassassembler.model.entities.ReferenceTableEntity;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Администратор
 * Date: 15.04.12
 * Time: 12:11
 * To change this template use File | Settings | File Templates.
 */
public class ReferenceTableImpl implements IViewModel, IReferenceTableModel {

    /**
     * Список команд операций
     */
    private List<String[]> _referencesList;

    private List<ReferenceTableEntity> _entities;

    public ReferenceTableImpl() {
        _referencesList = new ArrayList<String[]>();
        _entities = new ArrayList<ReferenceTableEntity>();
    }

//    @Override
//    public void firstPass(String s) {
//        //To change body of implemented methods use File | Settings | File Templates.
//    }

    @Override
    public List<String[]> getReferenceTableElements() {
        return _referencesList;
    }

    @Override
    public List<ReferenceTableEntity> getReferenceTableEntities() {
        return _entities;
    }

    @Override
    public boolean add(ReferenceTableEntity entity) {
        _referencesList.add(new String[]{entity.get_address(), entity.get_code(), entity.get_operand()});
        return _entities.add(entity);
    }

    @Override
    public void reset() {
        _referencesList = new ArrayList<String[]>();
        _entities = new ArrayList<ReferenceTableEntity>();
    }

}
